package internal

import (
	mqhttpsdk "github.com/aliyunmq/mq-http-go-sdk"
	"github.com/apache/rocketmq-client-go/v2/consumer"
	"github.com/apache/rocketmq-client-go/v2/primitive"
)

type (
	ConsumeMessageEntry    = mqhttpsdk.ConsumeMessageEntry
	ConsumeMessageResponse = mqhttpsdk.ConsumeMessageResponse
	ErrAckItem             = mqhttpsdk.ErrAckItem
	PublishMessageRequest  = mqhttpsdk.PublishMessageRequest
	PublishMessageResponse = mqhttpsdk.PublishMessageResponse
)

type (
	Message               = primitive.Message
	MessageExt            = primitive.MessageExt
	TransactionSendResult = primitive.TransactionSendResult
	TransactionListener   = primitive.TransactionListener
	LocalTransactionState = primitive.LocalTransactionState

	MessageSelector = consumer.MessageSelector
	ConsumeResult   = consumer.ConsumeResult
)

const (
	UnknownState         = primitive.UnknowState
	CommitMessageState   = primitive.CommitMessageState
	RollbackMessageState = primitive.RollbackMessageState
)

const (
	TAG = consumer.TAG
)

const (
	ConsumeSuccess             = consumer.ConsumeSuccess
	ConsumeRetryLater          = consumer.ConsumeRetryLater
	Commit                     = consumer.Commit
	Rollback                   = consumer.Rollback
	SuspendCurrentQueueAMoment = consumer.SuspendCurrentQueueAMoment
)

const (
	DefaultApacheGroupId = "default_group_id"
)

const (
	StartDeliverTime       = "__STARTDELIVERTIME"
	TransCheckImmunityTime = "__TransCheckT"
	Keys                   = "KEYS"
	SHARDING               = "__SHARDINGKEY"
)

type ConsumeMessage struct {
	Messages ConsumeMessageEntry
}

type ConsumeMessageAck struct {
	// 消息ID
	MessageID string `xml:"MessageId" json:"message_id"`
	// 消息句柄只有事务消息才有
	ReceiptHandle string `xml:"ReceiptHandle" json:"receipt_handle"`
	// 事务处理结果
	Transaction int64 `xml:"Transaction" json:"transaction"`
}

const (
	RocketMqAliyun = "aliyun"
	RocketMqApache = "apache"
)
